//
//  SystemCenter.m
//  cutter
//
//  Created by mac on 16/3/30.
//  Copyright © 2016年 e360. All rights reserved.
//
#import "SystemCenter.h"
@interface SystemCenterTableCell : UITableViewCell
@end
@implementation SystemCenterTableCell
-(void)setSelected:(BOOL)selected animated:(BOOL)animated{
    [super setSelected:selected animated:animated];
    UIButton *view = [[self.contentView subviews] firstObject];
    if (view) {
        [view setSelected:selected];
    }
}
@end
//
@interface SystemCenterTable : UITableViewController
@end
@implementation SystemCenterTable
-(void)viewDidLoad{
    [super viewDidLoad];
    [self setClearsSelectionOnViewWillAppear:NO];
    //
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
    [self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 4) {
        [UIAlertController show:@"确定要清除缓存吗？" message:@"清除缓存后，所有已加载的产品、搭配、方案等图片，都将被删除。" buttons:@[@"清除",@"取消"] handler:^(UIAlertAction *action) {
            if ([action.title isEqualToString:@"清除"]) {
                
            }
        }];
    }
    if (indexPath.row == 5) {
        [UIAlertController show:nil message:@"确定要退出吗？" buttons:@[@"退出",@"取消"] handler:^(UIAlertAction *action) {
            if ([action.title isEqualToString:@"退出"]) {
                UINavigationController *root = (id)[[[UIApplication sharedApplication] keyWindow] rootViewController];
                [root dismissViewControllerAnimated:YES completion:nil];
                if ([root isKindOfClass:UINavigationController.class]) {
                    [root popToRootViewControllerAnimated:YES];
                }
            }
        }];
    }
}
-(IBAction)exitTouch:(UIButton *)sender {
    IndexHomeCtrl *tabbar = (id)self.splitViewController.splitViewController;
    if ([tabbar isKindOfClass:IndexHomeCtrl.class]) {
        [tabbar showMenu];
    }
}
@end
//
@implementation SystemCenter
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setMinimumPrimaryColumnWidth:254];
    [self setMaximumPrimaryColumnWidth:254];
}
-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    [self.bgView setFrame:self.view.bounds];
    [self.view insertSubview:self.bgView atIndex:0];
}
@end
